package com.itheima.app.controller;

import com.itheima.app.manager.LingHunManger;
import com.itheima.domain.vo.AnswersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class LingHunController {
    @Autowired
    private LingHunManger lingHunManger;

    //测灵魂-问卷列表
    @GetMapping("/testSoul")
    public ResponseEntity testSoul() {
        return lingHunManger.testSoul();
    }

    //测灵魂-提交问卷
    @PostMapping("/testSoul")
    public ResponseEntity testSoul(@RequestBody Map<String,List<AnswersVo>> map) {
        List<AnswersVo> answers = map.get("answers");
        System.out.println(answers);
        lingHunManger.testSoul(answers);
        return ResponseEntity.ok("748");
    }
    //测灵魂-查看结果
    @GetMapping("/testSoul/report/{id}")
    public ResponseEntity testResult(@PathVariable Long id) {
        System.out.println(id);
        return lingHunManger.report(id);
    }
}
